<?php
error_reporting(E_ALL);
require_once "lib/WebElement.php";

class index extends lib{
	public function __construct()
	{
		//element 1 for testing clonning mechanism
		$element1 = new WebElement;
		$element1->setText("Element 1".$element1->getID());
		$element1->setAttribute("style","background:red");
                $element1->addClass('ala');
                $element1->addClass('ala');
                $element1->addClass('bala');
                $element1->addClass('bala');
                $element1->addClass('portocala');
                $element1->removeClass('bala');
                var_dump($element1);

                $element11 = clone $element1;
                $element11->setText("Element 11 ".$element11->getID());
                //var_dump($element11);
		
		//element2 for testing positioning mechanism
		$element2 = new Element;
		$element2->setText("Element 2".$element2->getID());

                //var_dump($element2);
		
		//element 3 for testing post-content display
		$element3 = new WebElement;
		$element3->setText("<b>Element 3</b>".$element3->getID());
                $element3->addClass('olele');
		
		//Wrapper declaration
		$wrapper = new Element;
		$wrapper->setText("Wrapper");
		
		//Test clonning
		$wrapper->addChild(clone $element1);
		
		//Test new attribute
		$element1->setAttribute("style","background:blue");
		$wrapper->addChild($element1);
		
		//test positinoning first
		$wrapper->addChild($element2,true,0);
		
		//test preparing for post-content display
		$wrapper->addChild($element3,false,1);

                $wrapper->addChild($element11);
		
		//setting the new tag
		$wrapper->setTag('body');
		
		echo "<!DOCTYPE HTML>";
		echo "<html>";
		echo "<head><title>TreiO</title></head>";
		//display elements
		$wrapper->toHtml();
		echo "</html>";
	}
	public static function main(){
		new index();
	}
} 

if(!isset($_SERVER['REDIRECT_QUERY_STRING']))
{
	/* no server redirect. this is not as sexy :( 
	If you are shore to have mod_rewrite enabled, delete this if. 
	it's worthless.
	
	I still use TO-core insted of something like index::main() 
	(witch in this case works the same, except faster) for portability - 
	if you rename the file to start some other page, you will only have to 
	rename the class above. maybe i'm just lazy
	*/
	include_once("TO-core.php");
	//index::main();
}